package types

type Listen struct {
	Addr string `yaml:"addr" json:"addr"`
	Port int    `yaml:"port" json:"port"`
}

type LogConf struct {
	Encoding   string `yaml:"encoding" json:"encoding"`
	TimeFormat string `yaml:"time_format" json:"time_format"`
	Stat       bool   `yaml:"stat" json:"stat"`
	Level      string `yaml:"level" json:"level"`
}

type Function struct {
	BlackList BlackList `yaml:"black_list"`
	Crontab   string    `yaml:"crontab"`
}

type BlackList struct {
	Haproxy   bool `yaml:"haproxy"`
	EBPF      bool `yaml:"ebpf"`
	Openresty bool `yaml:"openresty"`
}

type ServiceURI struct {
	BlackListURI *BlackListURI `json:"blacklist"`
}

type BlackListURI struct {
	GetHaproxyIPBlackListDataURI    string `json:"haproxy"`
	GetEBPFIPBlackListDataURI       string `json:"ebpf"`
	GetOpenrestryIPBlackListDataURI string `json:"openresty"`
}

func NewServiceURI() *ServiceURI {
	return &ServiceURI{
		BlackListURI: &BlackListURI{
			GetHaproxyIPBlackListDataURI:    "/api/v1/blacklist/haproxy",
			GetEBPFIPBlackListDataURI:       "/api/v1/blacklist/ebpf",
			GetOpenrestryIPBlackListDataURI: "/api/v1/blacklist/openresty",
		},
	}
}

type PublicResponse[T any] struct {
	Code int32
	Msg  string
	Data T
}

type BlacklistData struct {
	Blacklist map[string]StringList `json:"blacklist"`
}

type StringList struct {
	Values []string `json:"values"`
	Port   string   `json:"port"`
	Count  int32    `json:"count"`
}
